package com.utils.httpservlet;

import java.io.Serializable;

/**
 * 调用结果反馈
 * code :默认：
 * httpstatus:            code:
 * 200,成功,             2000
 * 201,创建成功                           2001
 * 400,客户端错误                     4000
 * 401,未授权                               4001
 * 404，未找到资源                   4004
 * 500内部错误                             5000
 * @author Bing
 *
 */
@SuppressWarnings("rawtypes")
public class Response<T> implements Serializable{
	
	    /**
	    * @Fields serialVersionUID :
	    */
	    
	private static final long serialVersionUID = 4587864902389362669L;
	private String responseCode="";
	private String responseDesc="";
	private T data;
	
	public Response responseCode(String responseCode){
		this.responseCode = responseCode;
		return this;
	}
	
	public Response responseDesc(String responseDesc){
		this.responseDesc = responseDesc;
		return this;
	}
	
	public Response data(T data){
		this.data = data;
		return this;
	}
	
	public String getResponseCode() {
		return responseCode;
	}

	public String getResponseDesc() {
		return responseDesc;
	}

	public T getData() {
		return data;
	}
	
	public boolean isSuccess() {
		if (this.responseCode.equals("2000")) {
			return true;
		}else {
			return false;
		}
	}


	
	    /* 
	    * @Description: 
	    * 
	    * @return
	    * @see java.lang.Object#toString()
	    */
	    
	@Override
	public String toString() {
		return "Response [responseCode=" + responseCode + ", responseDesc=" + responseDesc + ", data=" + data + "]";
	}
	
}
